Imports System.Data.Common
Partial Class Presentation_ChangePassword
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Page.Title = "Password Change"



    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim Sql As String
        Dim Params(1) As GenParameter

        If Not Page.IsValid Then
            Return
        End If

        If NewPass.Text = ConfirmNewPass.Text Then

            Sql = "UPDATE ExecutiveMaster SET UserPassword = sha1(?UserPassword)" & _
                        " WHERE ExecutiveUserName = ?UserName"

            Params(0) = New GenParameter("?UserPassword", NewPass.Text, Data.DbType.String)
            Params(1) = New GenParameter("?UserName", Request.Cookies("Profile").Item("ExecutiveUserName").ToString, Data.DbType.String)


            Try
                GenHelper.ExecuteNonQuery(Sql, Params, ConfigurationManager.ConnectionStrings.Item("MySqlConnString").ToString())

            Catch ex As Exception

                MsgBox(ex.Message)

            End Try

            UpdateStatus.Text = "Update Successful. Please Logout and Login with your new Password"
            UpdateStatus.Visible = True

            FormsAuthentication.SignOut()

        Else
            UpdateStatus.Text = "Your Passwords are not the same! Please try again"
            UpdateStatus.Visible = True
            Exit Sub

        End If

    End Sub
End Class
